<!DOCTYPE html>
<html>

<head>
	<include file="public@head" title="邮箱设置" />
</head>

<body class="layui-layout-admin">
	<include file="public@header" />
	<include file="public@side" />

	<div class="layui-body">
		<div class="layui-breadcrumb" lay-filter="breadcrumb">
			<a href="{:url('admin/index/index')}">主页</a>
			<a>系统设置</a>
			<a href="{:url('admin/mailer/index')}"><cite>邮箱设置</cite></a>
		</div>
		<!--<div class="layui-tab">
		<ul class="layui-tab-title">
			<li class="layui-this"><a href="{:url('admin/mailer/index')}">邮箱设置</a></li>
			<li><a href="{:url('admin/mailer/template')}">邮件模板</a></li>
		</ul>
	</div> -->
		<div class="layui-fluid">
			<div class="layui-row">
				<div class="layui-card">
					<div class="layui-card-header">
						邮箱设置
					</div>
					<div class="layui-card-body layui-row">
						<form method="post" class="layui-form layui-col-md6" action="{:url('admin/mailer/index')}">
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="form-required">*</span>发件人</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" lay-verify="required" name="from_name" value="{$from_name|default=''}">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="form-required">*</span>邮箱地址</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" lay-verify="required|email" name="from" value="{$from|default=''}">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="form-required">*</span>SMTP服务器</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" lay-verify="required" name="host" value="{$host|default=''}">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="form-required">*</span>SMTP链接</label>
								<div class="layui-input-inline">
									<select name="smtp_secure">
										<option value="">默认</option>
										<option value="ssl">ssl</option>
										<option value="tls">tls</option>
									</select>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="form-required">*</span>SMTP服务器端口</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" lay-verify="required|number" name="port" value="{$port|default=''}" placeholder="默认为25">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="form-required">*</span>发件箱账号</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" lay-verify="required|email" name="username" value="{$username|default=''}">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="form-required">*</span>发件箱密码</label>
								<div class="layui-input-block">
									<input type="password" class="layui-input" lay-verify="required" name="password" value="{$password|default=''}">
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-input-block">
									<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="save">保存修改</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<include file="public@scripts" />
	<script>
        form.on('submit(save)', function(data) {
            $.post(data.action, data.field, function(res) {
                layer.msg(res.msg, {}, function() {
                    if(res.url) { //如果返回值有需要跳转的url则跳转，否则重载当前页面
                        window.location.href = res.url;
                    }
                    else {
                        window.location.reload();
                    }
                });
            });
            return false;
        });
	</script>
</body>

</html>
